* ======================================
* --- Baseline results w/ geo-time fe --
* ======================================


	use $dta\EstimationSample.dta, clear



* Estimate models
* ===============	
	
	
	egen bsuperiod = group(Voter_bsu year)	
	egen idbsu = group(Voter_id Voter_bsu)
	estimates clear	
	
	foreach net in Fam1 Fam2 Work1 Work2 Imm1 Imm2 {
	
		preserve
	
		keep if `net' == 1 	// set sample
	
		sum Voter_turnout 	// mean depvar
		local meandepvar = string(r(mean)*100, "%15.2fc")
	
		gen Any = `net'Any
		gen Same = `net'Same
		eststo m_`net': reghdfe Voter_turnout Any Same, ///
			absorb(idbsu bsuperiod) vce(cluster Voter_bsu)
		quietly estadd local meandep `meandepvar', replace

		restore
	}


* Export table
* ============

	esttab m_* ///
		using $tbls\Baseline_geotime.tex, replace  style(tex) ///
		prehead("\begin{tabular}{l*{7}{c}} \hline\hline \\  ") ///
		posthead("\hline \\") ///
		fragment ///
		mtitles("Close" "Extended" "Age-estbl." "Estbl." "3-digit" "2-digit") ///
		mgroups("\shortstack{\\ Family}" "\shortstack{\\ \\ Co-workers}" ///
			"\shortstack{\\ \\ Immigrants}", pattern(1 0 1 0 1 0) ///
			span prefix(\multicolumn{@span}{c}{) suffix(}) ///
			end(\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7})) ///
		label se b(%9.3f) se(%9.3f) nostar ///
		refcat(Any "\shortstack{ No candidate in network }") ///
		coeflabels(Any "Any District" Same "Same District" ) ///
		drop(_cons) noomitted nobaselevels ///
		nonotes stats(N N_clust meandep, labels( ///
			"Observations" "Clusters" "Mean turnout (\%)") ///
			fmt(%15.0fc %15.0fc %15.0fc)) ///
			substitute(\_ _) ///
		prefoot("\hline") ///
		postfoot("\hline\hline \\ \end{tabular}")
	